home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / demo / wemdemo4.zip / INFO / ELISP.14 < prev    next >
Text File  |  1994-09-21  |  50KB  |  1,248 lines

  1. Info file elisp, produced by Makeinfo, -*- Text -*- from input file
  2. elisp.texi.
  3.  
  4.    This file documents GNU Emacs Lisp.
  5.  
  6.    This is edition 1.03 of the GNU Emacs Lisp Reference Manual,   for
  7. Emacs Version 18.
  8.  
  9.    Published by the Free Software Foundation, 675 Massachusetts
  10. Avenue,  Cambridge, MA 02139 USA
  11.  
  12.    Copyright (C) 1990 Free Software Foundation, Inc.
  13.  
  14.    Permission is granted to make and distribute verbatim copies of
  15. this manual provided the copyright notice and this permission notice
  16. are preserved on all copies.
  17.  
  18.    Permission is granted to copy and distribute modified versions of
  19. this manual under the conditions for verbatim copying, provided that
  20. the entire resulting derived work is distributed under the terms of a
  21. permission notice identical to this one.
  22.  
  23.    Permission is granted to copy and distribute translations of this
  24. manual into another language, under the above conditions for modified
  25. versions, except that this permission notice may be stated in a
  26. translation approved by the Foundation.
  27.  
  28.  
  29. 
  30. File: elisp,  Node: Subroutines of Visiting,  Prev: Visiting Functions,  Up: Visiting Files
  31.  
  32. Subroutines of Visiting
  33. -----------------------
  34.  
  35.    The `find-file-noselect' function uses the `create-file-buffer'
  36. and `after-find-file' functions as subroutines.  Sometimes it is
  37. useful to call them directly.
  38.  
  39.  * Function: create-file-buffer FILENAME
  40.      This function creates a suitably named buffer for visiting
  41.      FILENAME, and returns it.  The string FILENAME (sans directory)
  42.      is used unchanged if that name is free; otherwise, a string such
  43.      as `<2>' is appended to get an unused name.  See also *Note
  44.      Creating Buffers::.
  45.  
  46.      *Note:* `create-file-buffer' does *not* associate the new buffer
  47.      with a file and does not make it the current buffer.
  48.  
  49.           (create-file-buffer "foo")
  50.                => #<buffer foo>
  51.           (create-file-buffer "foo")
  52.                => #<buffer foo<2>>
  53.           (create-file-buffer "foo")
  54.                => #<buffer foo<3>>
  55.  
  56.      This function is used by `find-file-noselect'.
  57.  
  58.  * Function: after-find-file &optional ERROR WARN
  59.      This function is called by `find-file-noselect' and by the
  60.      default revert function (*note Reverting::.).  It sets the
  61.      buffer major mode, and parses local variables (*note Auto Major
  62.      Mode::.).
  63.  
  64.      If there was an error in opening the file, the calling function
  65.      should pass ERROR a non-`nil' value.  In that case,
  66.      `after-find-file' issues a warning: `(New File)'.  Note that,
  67.      for serious errors, you would not even call `after-find-file'. 
  68.      Only "file not found" errors get here with a non-`nil' ERROR.
  69.  
  70.      If WARN is non-`nil', then this function issues a warning if an
  71.      auto-save file exists and is more recent than the visited file.
  72.  
  73.      The last thing `after-find-file' does is call all the functions
  74.      in `find-file-hooks'.
  75.  
  76.  
  77. 
  78. File: elisp,  Node: Saving Buffers,  Next: Reading from Files,  Prev: Visiting Files,  Up: Files
  79.  
  80. Saving Buffers
  81. ==============
  82.  
  83.    When you edit a file in Emacs, you are actually working on a
  84. buffer that is visiting that file--that is, the contents of the file
  85. are copied into the buffer and the copy is what you edit.  Changes to
  86. the buffer do not change the file until you "save" the buffer, which
  87. means copying the contents of the buffer into the file.
  88.  
  89.  * Command: save-buffer &optional BACKUP-OPTION
  90.      This function saves the contents of the current buffer in its
  91.      visited file if the buffer has been modified since it was last
  92.      visited or saved.  Otherwise it does nothing.
  93.  
  94.      `save-buffer' is responsible for making backup files.  Normally,
  95.      BACKUP-OPTION is `nil', and `save-buffer' makes a backup file
  96.      only if this is the first save or if the buffer was previously
  97.      modified.  Other values for BACKUP-OPTION request the making of
  98.      backup files in other circumstances:
  99.  
  100.         * With an argument of 4 or 64, reflecting 1 or 3 `C-u''s, the
  101.           `save-buffer' function marks this version of the file to be
  102.           backed up when the buffer is next saved.
  103.  
  104.         * With an argument of 16 or 64, reflecting 2 or 3 `C-u''s,
  105.           the `save-buffer' function unconditionally backs up the
  106.           previous version of the file before saving it.
  107.  
  108.  * Command: save-buffers-kill-emacs &optional KILL-SILENTLY-P
  109.      This function offers to save each buffer that needs to be saved,
  110.      and then kills the Emacs job.  With a non-`nil' value of the
  111.      optional KILL-SILENTLY-P argument, it unconditionally and
  112.      silently saves all the file-visiting buffers, and then kills the
  113.      job.
  114.  
  115.      The `save-buffers-kill-emacs' function is defined as follows:
  116.  
  117.           (defun save-buffers-kill-emacs (&optional arg)
  118.             "Offer to save each buffer, then kill this Emacs fork..."
  119.             (interactive "P")
  120.             (save-some-buffers arg t)
  121.             (kill-emacs))
  122.  
  123.  * Command: save-some-buffers &optional SAVE-SILENTLY-P EXITING
  124.      This command saves some modified file-visiting buffers. 
  125.      Normally it asks the user about each buffer.  If the function is
  126.      called with a non-`nil' value of the optional SAVE-SILENTLY-P
  127.      argument, this function saves all the file-visiting buffers
  128.      without querying the user.
  129.  
  130.      The optional EXITING argument, if non-`nil', requests this
  131.      function to offer also to save certain other buffers that are
  132.      not visiting files.  These are buffers that have a non-`nil'
  133.      local value of `buffer-offer-save'.  (A user who says yes to
  134.      saving one of these will be asked to specify a file name to
  135.      use.)  The `save-buffers-kill-emacs' function passes a non-`nil'
  136.      value for this argument.
  137.  
  138.  * Variable: buffer-offer-save
  139.      When this variable is non-`nil' in a buffer, Emacs offers to
  140.      save the buffer on exit even if the buffer is not visiting a
  141.      file.  The variable is automatically local in all buffers. 
  142.      Normally, Mail mode (used for editing outgoing mail) sets this
  143.      to `t'.
  144.  
  145.  * Command: write-file FILENAME
  146.      This function writes the current buffer into file FILENAME,
  147.      makes the buffer visit that file, and marks it not modified. 
  148.      The buffer is renamed to correspond to FILENAME unless that name
  149.      is already in use.
  150.  
  151.  * Variable: write-file-hooks
  152.      The value of this variable is a list of functions to be called
  153.      before writing out a buffer to its visited file.  If one of them
  154.      returns non-`nil', the file is considered already written and
  155.      the rest of the functions are not called, nor is the usual code
  156.      for writing the file executed.
  157.  
  158.      If the `file-precious-flag' variable is `nil', the file is moved
  159.      to the backup file before any of the hooks are called.  If none
  160.      of the hooks actually write the file, but one does return
  161.      non-`nil', the file will not exist, although the backup will.
  162.  
  163.      Here is an example showing how to add an element to
  164.      `write-file-hooks' but avoid adding it twice:
  165.  
  166.           (or (memq 'my-write-file-hook write-file-hooks)
  167.               (setq write-file-hooks 
  168.                     (cons 'my-write-file-hook write-file-hooks)))
  169.  
  170.  * Variable: file-precious-flag
  171.      If this variable is non-`nil', then `save-buffer' protects
  172.      against I/O errors while saving by renaming the original file to
  173.      a temporary name before writing the new contents of the file. 
  174.      If the new contents are successfully written, the renamed
  175.      original file is deleted.  Otherwise, it is renamed back to the
  176.      original name.  This procedure prevents problems such as a lack
  177.      of disk space from resulting in an invalid file.
  178.  
  179.      Some modes set this non-`nil' locally in particular buffers.
  180.  
  181.  * User Option: require-final-newline
  182.      This variable determines whether files may be written out that
  183.      do *not* end with a newline.  If the value of the variable is
  184.      `t', then Emacs silently puts a newline at the end of the file
  185.      whenever the buffer being saved does not already end in one.  If
  186.      the value of the variable is non-`nil', but not `t', then Emacs
  187.      asks the user whether to add a newline each time the case arises.
  188.  
  189.      If the value of the variable is `nil', then Emacs doesn't add
  190.      newlines at all.  `nil' is the default value, but a few major
  191.      modes change it to `t'.
  192.  
  193.  
  194. 
  195. File: elisp,  Node: Reading from Files,  Next: Writing to Files,  Prev: Saving Buffers,  Up: Files
  196.  
  197. Reading from Files
  198. ==================
  199.  
  200.    You can copy a file directly from the disk and insert it into a
  201. buffer using the `insert-file-contents' function, or its interactive
  202. variant, `insert-file'.
  203.  
  204.  * Command: insert-file FILENAME
  205.      This function inserts the contents of file FILENAME into the
  206.      current buffer after point, and sets the mark at the end of the
  207.      inserted text.  An error is signaled if FILENAME is not the name
  208.      of a file that can be read.  This function is for interactive
  209.      use and does little more than call `insert-file-contents'.
  210.  
  211.  * Function: insert-file-contents FILENAME &optional VISIT
  212.      This function inserts the contents of file FILENAME into the
  213.      current buffer after point. It returns a list of the absolute
  214.      file name and the length of the data inserted.  An error is
  215.      signaled if FILENAME is not the name of a file that can be read.
  216.  
  217.      If VISIT is non-`nil', it also marks the buffer as unmodified
  218.      and sets up various fields in the buffer so that it is visiting
  219.      the file FILENAME: these include the buffer's visited file name
  220.      and its last save file modtime.  This feature is used by
  221.      `find-file-noselect' and you should probably not use it yourself.
  222.  
  223.  
  224. 
  225. File: elisp,  Node: Writing to Files,  Next: File Locks,  Prev: Reading from Files,  Up: Files
  226.  
  227. Writing to Files
  228. ================
  229.  
  230.    You can write the contents of a buffer, or part of a buffer,
  231. directly to a file on disk using the `append-to-file' and
  232. `write-region' functions.  Don't use these functions to write to
  233. files that are being visited; that could cause confusion in the
  234. mechanisms for visiting.
  235.  
  236.  * Command: append-to-file START END FILENAME
  237.      This function appends the contents of the region delimited by
  238.      START and END in the current buffer to the end of file FILENAME.
  239.      If that file does not exist, it is created.  This function
  240.      returns `nil'.
  241.  
  242.      An error is signaled if FILENAME specifies a nonwritable file,
  243.      or a nonexistent file in a directory where files cannot be
  244.      created.
  245.  
  246.  * Command: write-region START END FILENAME &optional APPEND VISIT
  247.      This function writes the region (of the current buffer)
  248.      delimited by START and END into the file specified by FILENAME.
  249.  
  250.      If APPEND is non-`nil', then the region is appended to the
  251.      existing file contents (if any).
  252.  
  253.      If VISIT is `t', then Emacs establishes an association between
  254.      the buffer and the file: the buffer is then visiting that file. 
  255.      It also sets the last file modification time for the current
  256.      buffer to FILENAME's modtime, and marks the buffer as not
  257.      modified.  This feature is used by `write-file' and you should
  258.      probably not use it yourself.
  259.  
  260.      Normally, this function displays a message `Wrote file FILENAME'
  261.      in the echo area.  If VISIT is neither `t' nor `nil', then this
  262.      message is inhibited.  This feature is useful for programs that
  263.      use files for internal purposes, files which the user does not
  264.      need to know about.
  265.  
  266.  
  267. 
  268. File: elisp,  Node: File Locks,  Next: Information about Files,  Prev: Writing to Files,  Up: Files
  269.  
  270. File Locks
  271. ==========
  272.  
  273.    When two users edit the same file at the same time, they are
  274. likely to interfere with each other.  Emacs tries to prevent this
  275. situation from arising by recording a "file lock" when a file is
  276. being modified.  Emacs can then detect the first attempt to modify a
  277. buffer visiting a file that is locked by another Emacs job, and ask
  278. the user what to do.
  279.  
  280.    File locks do not work properly when multiple machines can share
  281. filesystems, such as with NFS.  Perhaps a better file locking system
  282. will be implemented in the future.  When file locks do not work, it
  283. is possible for two users to make changes simultaneously, but Emacs
  284. will still be able to warn the user who saves second.  Also, the
  285. detection of modification of a buffer visiting a file changed on disk
  286. catches some cases of simultaneous editing; see *Note Modification
  287. Time::.
  288.  
  289.  * Function: file-locked-p FILENAME
  290.      This function returns `nil' if the file FILENAME is not locked
  291.      by this Emacs process.  It returns `t' if it is locked by this
  292.      Emacs, and it returns the name of the user who has locked it if
  293.      it is locked by someone else.
  294.  
  295.           (file-locked-p "foo")
  296.                => nil
  297.  
  298.  * Function: lock-buffer &optional FILENAME
  299.      This function locks the file FILENAME, if the current buffer is
  300.      modified.  The argument FILENAME defaults to the current
  301.      buffer's visited file.  Nothing is done if the current buffer is
  302.      not visiting a file, or is not modified.
  303.  
  304.  * Function: unlock-buffer
  305.      This function unlocks the file being visited in the current
  306.      buffer, if the buffer is modified.  If the buffer is not
  307.      modified, then the file should not be locked, so this function
  308.      does nothing.  It also does nothing if the current buffer is not
  309.      visiting a file.
  310.  
  311.  * Function: ask-user-about-lock FILE OTHER-USER
  312.      This function is called when the user tries to modify FILE, but
  313.      it is locked by another user name OTHER-USER.  The value it
  314.      returns controls what Emacs will do with the file:
  315.  
  316.         * A value of `t' tells Emacs to grab the lock on the file. 
  317.           Then this user may edit the file and OTHER-USER loses the
  318.           lock.
  319.  
  320.         * A value of `nil' tells Emacs to ignore the lock and let
  321.           this user edit the file anyway.
  322.  
  323.         * This function may instead signal a `file-locked' error, in
  324.           which case the change to the buffer which the user was
  325.           about to make does not take place.
  326.  
  327.           The error message for this error looks like this:
  328.  
  329.                error--> File is locked: FILE OTHER-USER
  330.  
  331.           where `file' is the name of the file and OTHER-USER is the
  332.           name of the user who has locked the file.
  333.  
  334.      The default definition of this function asks the user to choose
  335.      what to do.  If you wish, you can replace the
  336.      `ask-user-about-lock' function with your own version that
  337.      decides in another way.  The code for its usual definition is in
  338.      `userlock.el'.
  339.  
  340.  
  341. 
  342. File: elisp,  Node: Information about Files,  Next: Contents of Directories,  Prev: File Locks,  Up: Files
  343.  
  344. Information about Files
  345. =======================
  346.  
  347.    The functions described in this section are similar in as much as
  348. they all operate on strings which are interpreted as file names.  All
  349. have names that begin with the word `file'.  These functions all
  350. return information about actual files or directories, so their
  351. arguments must all exist as actual files or directories unless
  352. otherwise noted.
  353.  
  354.    Most of the file-oriented functions take a single argument,
  355. FILENAME, which must be a string.  The file name is expanded using
  356. `expand-file-name', so `~' is handled correctly, as are relative file
  357. names (including `../').  Environment variable substitutions, such as
  358. `$HOME', are not recognized by these functions.
  359.  
  360. * Menu:
  361.  
  362. * Testing Accessibility::   Is a given file readable?  Writable?
  363. * Kinds of Files::          Is it a directory?  A link?
  364. * File Attributes::         How large is it?  Any other names?  Etc.
  365.  
  366.  
  367. 
  368. File: elisp,  Node: Testing Accessibility,  Next: Kinds of Files,  Prev: Information about Files,  Up: Information about Files
  369.  
  370. Testing Accessibility
  371. ---------------------
  372.  
  373.    These functions test for permission to access a file in specific
  374. ways.
  375.  
  376.  * Function: file-exists-p FILENAME
  377.      This function returns `t' if a file named FILENAME appears to
  378.      exist.  This does not mean you can necessarily read the file,
  379.      only that you can find out its attributes.  (On Unix, this is
  380.      true if the file exists and you have execute permission on the
  381.      containing directories, regardless of the protection of the file
  382.      itself.)
  383.  
  384.      If the file does not exist, or if fascist access control
  385.      policies prevent you from finding the attributes of the file,
  386.      this function returns `nil'.
  387.  
  388.  * Function: file-readable-p FILENAME
  389.      This function returns `t' if a file named FILENAME exists and
  390.      you can read it.  It returns `nil' otherwise.
  391.  
  392.           (file-readable-p "files.texi")
  393.                => t
  394.           (file-exists-p "/usr/spool/mqueue")
  395.                => t
  396.           (file-readable-p "/usr/spool/mqueue")
  397.                => nil
  398.  
  399.  * Function: file-writable-p FILENAME
  400.      This function returns `t' if FILENAME can be written or created
  401.      by you.  It is writable if the file exists and you can write it.
  402.      It is creatable if the file does not exist, but the specified
  403.      directory does exist and you can write in that directory. 
  404.      `file-writable-p' returns `nil' otherwise.
  405.  
  406.      In the third example below, `foo' is not writable because the
  407.      parent directory does not exist, even though the user could
  408.      create it.
  409.  
  410.           (file-writable-p "~rms/foo")
  411.                => t
  412.           (file-writable-p "/foo")
  413.                => nil
  414.           (file-writable-p "~rms/no-such-dir/foo")
  415.                => nil
  416.  
  417.  * Function: file-newer-than-file-p FILENAME1 FILENAME2
  418.      This functions returns `t' if the file FILENAME1 is newer than
  419.      file FILENAME2.  If FILENAME1 does not exist, it returns `nil'. 
  420.      If FILENAME2 does not exist, it returns `t'.
  421.  
  422.      In the following example, assume that the file `aug-19' was
  423.      written on the 19th, and `aug-20' was written on the 20th.  The
  424.      file `no-file' doesn't exist at all.
  425.  
  426.           (file-newer-than-file-p "aug-19" "aug-20")
  427.                => nil
  428.           (file-newer-than-file-p "aug-20" "aug-19")
  429.                => t
  430.           (file-newer-than-file-p "aug-19" "no-file")
  431.                => t
  432.           (file-newer-than-file-p "no-file" "aug-19")
  433.                => nil
  434.  
  435.  
  436. 
  437. File: elisp,  Node: Kinds of Files,  Next: File Attributes,  Prev: Testing Accessibility,  Up: Information about Files
  438.  
  439. Distinguishing Kinds of Files
  440. -----------------------------
  441.  
  442.    This section describes how to distinguish directories and symbolic
  443. links from ordinary files.
  444.  
  445.  * Function: file-symlink-p FILENAME
  446.      If FILENAME is a symbolic link, the `file-symlink-p' function
  447.      returns the file name to which it is linked.  This may be the
  448.      name of a text file, a directory, or even another symbolic link,
  449.      or of no file at all.
  450.  
  451.      If FILENAME is not a symbolic link (or there is no such file),
  452.      `file-symlink-p' returns `nil'.
  453.  
  454.           (file-symlink-p "foo")
  455.                => nil
  456.           (file-symlink-p "sym-link")
  457.                => "foo"
  458.           (file-symlink-p "sym-link2")
  459.                => "sym-link"
  460.           (file-symlink-p "/bin")
  461.                => "/pub/bin"
  462.  
  463.  * Function: file-directory-p FILENAME
  464.      This function returns `t' if FILENAME is the name of an existing
  465.      directory, `nil' otherwise.
  466.  
  467.           (file-directory-p "~rms")
  468.                => t
  469.           (file-directory-p "~rms/lewis/files.texi")
  470.                => nil
  471.           (file-directory-p "~rms/lewis/no-such-file")
  472.                => nil
  473.           (file-directory-p "$HOME")
  474.                => nil
  475.           (file-directory-p (substitute-in-file-name "$HOME"))
  476.                => t
  477.  
  478.  
  479. 
  480. File: elisp,  Node: File Attributes,  Prev: Kinds of Files,  Up: Information about Files
  481.  
  482. Other Information about Files
  483. -----------------------------
  484.  
  485.    This section describes the functions for getting detailed
  486. information about a file, other than its contents.  This information
  487. includes the mode bits that control access permission, the owner and
  488. group numbers, the number of names, the inode number, the size, and
  489. the times of access and modification.
  490.  
  491.  * Function: file-modes FILENAME
  492.      This function returns the mode bits of FILENAME, as an integer. 
  493.      The mode bits are also called the file permissions, and they
  494.      specify access control in the usual Unix fashion.  If the
  495.      low-order bit is 1, then the file is executable by all users, if
  496.      the second lowest-order bit is 1, then the file is writable by
  497.      all users, etc.
  498.  
  499.      The highest value returnable is 4095 (7777 octal), meaning that
  500.      everyone has read, write, and execute permission, that the SUID
  501.      bit is set for both others and group, and that the sticky bit is
  502.      set.
  503.  
  504.           (file-modes "~/junk/diffs")
  505.                => 492               ; decimal integer
  506.           (format "%o" 492)
  507.                => 754               ; convert to octal
  508.           
  509.           (set-file-modes "~/junk/diffs" 438)
  510.                => nil
  511.           
  512.           (format "%o" 438)
  513.                => 666               ; convert to octal
  514.           
  515.           % ls -l diffs
  516.             -rw-rw-rw-  1 lewis    0    3063 Oct 30 16:00 diffs
  517.  
  518.  * Function: file-nlinks FILENAME
  519.      This functions returns the number of names (i.e., hard links)
  520.      that file FILENAME has.  If the file does not exist, then this
  521.      function returns `nil'.  Note that symbolic links have no effect
  522.      on this function, because they are not considered to be names of
  523.      the files they link to.
  524.  
  525.           % ls -l foo*
  526.           -rw-rw-rw-  2 rms             4 Aug 19 01:27 foo
  527.           -rw-rw-rw-  2 rms             4 Aug 19 01:27 foo1
  528.           
  529.           (file-nlinks "foo")
  530.                => 2
  531.           (file-nlinks "doesnt-exist")
  532.                => nil
  533.  
  534.  * Function: file-attributes FILENAME
  535.      This function returns a list of attributes of file FILENAME.  If
  536.      the specified file cannot be opened, it returns `nil'.
  537.  
  538.      The elements of the list, in order, are:
  539.  
  540.        1. `t' for a directory, a string for a symbolic link (the name
  541.           linked to), or `nil' for a text file.
  542.  
  543.        2. The number of names the file has.  Alternate names, also
  544.           known as hard links, can be created with `add-name-to-file'
  545.           (*note Changing File Attributes::.).
  546.  
  547.        3. The file's UID.
  548.  
  549.        4. The file's GID.
  550.  
  551.        5. The time of last access, as a list of two integers.  The
  552.           first integer has the high-order 16 bits of time, the
  553.           second has the low 16 bits.
  554.  
  555.        6. The time of last modification as a list of two integers (as
  556.           above).
  557.  
  558.        7. The time of last status change as a list of two integers
  559.           (as above).
  560.  
  561.        8. The size of the file in bytes.
  562.  
  563.        9. The file's modes, as a string of ten letters or dashes as
  564.           in `ls -l'.
  565.  
  566.       10. `t' if the file's GID would change if file were deleted and
  567.           recreated; `nil' otherwise.
  568.  
  569.       11. The file's inode number.
  570.  
  571.      For example, here are the file attributes for `files.texi':
  572.  
  573.           (file-attributes "files.texi")
  574.                =>  (nil 
  575.                     1 
  576.                     2235 
  577.                     75 
  578.                     (8489 20284) 
  579.                     (8489 20284) 
  580.                     (8489 20285)
  581.                     14906 
  582.                     "-rw-rw-rw-" 
  583.                     nil 
  584.                     20920)
  585.  
  586.      and here is how the result is interpreted:
  587.  
  588.     `nil'
  589.           is neither a directory nor a symbolic link.
  590.  
  591.     `1'
  592.           has only one name (the name `files.texi' in the current
  593.           default directory).
  594.  
  595.     `2235'
  596.           is owned by the user with UID 2235.
  597.  
  598.     `75'
  599.           is in the group with GID 75.
  600.  
  601.     `(8489 20284)'
  602.           was last accessed on Aug 19 00:09.  Unfortunately, you
  603.           cannot convert this number into a time string in Emacs.
  604.  
  605.     `(8489 20284)'
  606.           was last accessed on Aug 19 00:09.
  607.  
  608.     `(8489 20285)'
  609.           last had its inode changed on Aug 19 00:09.
  610.  
  611.     `14906'
  612.           is 14906 characters long.
  613.  
  614.     `"-rw-rw-rw-"'
  615.           has a mode of read and write access for the owner, group,
  616.           and world.
  617.  
  618.     `nil'
  619.           would retain the same GID if it were recreated.
  620.  
  621.     `20920'
  622.           has an inode number of 20920.
  623.  
  624.  
  625. 
  626. File: elisp,  Node: Contents of Directories,  Next: Changing File Attributes,  Prev: Information about Files,  Up: Files
  627.  
  628. Contents of Directories
  629. =======================
  630.  
  631.    A directory is a kind of file that contains other files entered
  632. under various names.  Directories are a feature of the file system.
  633.  
  634.    Emacs can list the names of the files in a directory as a Lisp
  635. list, or display the names in a buffer using the `ls' shell command. 
  636. In the latter case, it can optionally display information about each
  637. file, depending on the value of switches passed to the `ls' command.
  638.  
  639.  * Function: directory-files DIRECTORY &optional FULL-NAME MATCH-REGEXP
  640.      This function returns a list of the names of the files in the
  641.      directory DIRECTORY.
  642.  
  643.      If FULL-NAME is non-`nil', the function returns the files'
  644.      absolute file names.  Otherwise, it returns just the names
  645.      relative to the specified directory.
  646.  
  647.      If MATCH-REGEXP is non-`nil', function returns only those file
  648.      names that contain that regular expression--the other file names
  649.      are discarded from the list.
  650.  
  651.           (directory-files "~lewis")
  652.                => ("#foo#" "#foo.el#" "." ".."
  653.                    "dired-mods.el" "files.texi" "files.texi.~1~")
  654.  
  655.      An error is signaled if DIRECTORY is not the name of a directory
  656.      that can be read.
  657.  
  658.  * Function: file-name-all-versions FILE DIRNAME
  659.      This function returns a list of all versions of the file named
  660.      FILE in directory DIRNAME.
  661.  
  662.  * Command: list-directory FILESPEC &optional VERBOSE
  663.      This command displays a list of files in or matching FILESPEC. 
  664.      It calls the shell command `ls', passing it options under the
  665.      control of VERBOSE.
  666.  
  667.      The argument FILESPEC may be either a directory name or a file
  668.      name containing optional wildcards.  Wildcards are processed by
  669.      the shell.
  670.  
  671.      The options passed to `ls' are the value of
  672.      `list-directory-verbose-switches' if VERBOSE is non-`nil';
  673.      `list-directory-brief-switches' otherwise.  Interactively, the
  674.      raw prefix argument is used for VERBOSE.
  675.  
  676.  * Variable: list-directory-brief-switches
  677.      This variable contains switches for `list-directory' to pass to
  678.      `ls' for a short or "brief" listing.  The default value is
  679.      `"-CF"'.
  680.  
  681.  * Variable: list-directory-verbose-switches
  682.      This variable contains switches for `list-directory' to pass to
  683.      `ls' for a verbose or "long" listing.  The default value is
  684.      `"-l"'.
  685.  
  686.  
  687. 
  688. File: elisp,  Node: Changing File Attributes,  Next: File Names,  Prev: Contents of Directories,  Up: Files
  689.  
  690. Changing File Names and Attributes
  691. ==================================
  692.  
  693.    The functions in this section rename, copy, delete, link, and set
  694. the modes of files.
  695.  
  696.    In the functions that have an argument NEWNAME, if a file by the
  697. name of NEWNAME already exists, the actions taken depend on the value
  698. of the argument OK-IF-ALREADY-EXISTS:
  699.  
  700.    * A `file-already-exists' error is signaled if
  701.      OK-IF-ALREADY-EXISTS is `nil'.
  702.  
  703.    * Confirmation is requested if OK-IF-ALREADY-EXISTS is a number.
  704.  
  705.    * No confirmation is requested if OK-IF-ALREADY-EXISTS is any
  706.      other value, in which case the old file is removed.
  707.  
  708.  * Function: add-name-to-file OLDNAME NEWNAME &optional
  709.           OK-IF-ALREADY-EXISTS
  710.      This function gives the file named OLDNAME the additional name
  711.      NEWNAME.  This means that NEWNAME will be a new "hard link" to
  712.      OLDNAME.
  713.  
  714.      In the first part of the following example, we list two files,
  715.      `foo' and `foo3'.
  716.  
  717.           % ls -l fo*
  718.           -rw-rw-rw-  1 rms            29 Aug 18 20:32 foo
  719.           -rw-rw-rw-  1 rms            24 Aug 18 20:31 foo3
  720.  
  721.      Then we evaluate the form `(add-name-to-file "~/lewis/foo"
  722.      "~/lewis/foo2")'.  Again we list the files.  This shows two
  723.      names, `foo' and `foo2'.
  724.  
  725.           (add-name-to-file "~/lewis/foo1" "~/lewis/foo2")
  726.                => nil
  727.           
  728.           % ls -l fo*
  729.           -rw-rw-rw-  2 rms            29 Aug 18 20:32 foo
  730.           -rw-rw-rw-  2 rms            29 Aug 18 20:32 foo2
  731.           -rw-rw-rw-  1 rms            24 Aug 18 20:31 foo3
  732.  
  733.      Finally, we evaluate `(add-name-to-file "~/lewis/foo"
  734.      "~/lewis/foo3" t)', and list the files again.  Now there are
  735.      three names for one file: `foo', `foo2', and `foo3'.  The old
  736.      contents of `foo3' are lost.
  737.  
  738.           (add-name-to-file "~/lewis/foo1" "~/lewis/foo3")
  739.                => nil
  740.           
  741.           % ls -l fo*
  742.           -rw-rw-rw-  3 rms            29 Aug 18 20:32 foo
  743.           -rw-rw-rw-  3 rms            29 Aug 18 20:32 foo2
  744.           -rw-rw-rw-  3 rms            29 Aug 18 20:32 foo3
  745.  
  746.      This function is meaningless on VMS, where multiple names for
  747.      one file are not allowed.
  748.  
  749.      See also `file-nlinks' in *Note Information about Files::.
  750.  
  751.  * Command: rename-file FILENAME NEWNAME &optional OK-IF-ALREADY-EXISTS
  752.      This command renames the file FILENAME as NEWNAME.
  753.  
  754.      If FILENAME has additional names aside from FILENAME, it
  755.      continues to have those names.  In fact, adding the name NEWNAME
  756.      with `add-name-to-file' and then deleting FILENAME has the same
  757.      effect as renaming, aside from momentary intermediate states.
  758.  
  759.      In an interactive call, this function prompts for FILENAME and
  760.      NEWNAME in the minibuffer; also, it requests confirmation if
  761.      NEWNAME already exists.
  762.  
  763.  * Command: copy-file OLDNAME NEWNAME &optional OK-IF-EXISTS TIME
  764.      This command copies the file OLDNAME to NEWNAME.  An error is
  765.      signaled if OLDNAME does not exist.
  766.  
  767.      If TIME is non-`nil', then this functions gives the new file the
  768.      same last-modified time that the old one has.  (This works on
  769.      only some operating systems.)
  770.  
  771.      In an interactive call, this function prompts for FILENAME and
  772.      NEWNAME in the minibuffer; also, it requests confirmation if
  773.      NEWNAME already exists.
  774.  
  775.  * Command: delete-file FILENAME
  776.      This command deletes the file FILENAME, like the shell command
  777.      `rm FILENAME'.  If the file has multiple names, it continues to
  778.      exist under the other names.
  779.  
  780.      A suitable kind of `file-error' error is signaled if the file
  781.      does not exist, or is not deletable.  (In Unix, a file is
  782.      deletable if its directory is writable.)
  783.  
  784.  * Command: make-symbolic-link FILENAME NEWNAME &optional OK-IF-EXISTS
  785.      This command makes a symbolic link to FILENAME, named NEWNAME. 
  786.      This is like the shell command `ln -s FILENAME NEWNAME'.
  787.  
  788.      In an interactive call, FILENAME and NEWNAME are read in the
  789.      minibuffer, and OK-IF-EXISTS is set to the numeric prefix
  790.      argument.
  791.  
  792.  * Function: set-file-modes FILENAME MODE
  793.      This function sets mode bits of FILENAME to MODE (which must be
  794.      a integer).  Only the 12 low bits of MODE are used.
  795.  
  796.  
  797. 
  798. File: elisp,  Node: File Names,  Prev: Changing File Attributes,  Up: Files
  799.  
  800. File Names
  801. ==========
  802.  
  803.    Files are generally referred to by their names, in Emacs as
  804. elsewhere.  File names in Emacs are represented as strings.  The
  805. functions that operate on a file all expect a file name argument.
  806.  
  807.    In addition to operating on files themselves, Emacs Lisp programs
  808. often need to operate on the names; i.e., to take them apart and to
  809. use part of a name to construct related file names.  This section
  810. describes how to manipulate file names.
  811.  
  812.    The functions in this section do not actually access files, so
  813. they can operate on file names that do not refer to an existing file
  814. or directory.
  815.  
  816.    On VMS, all these functions understand both VMS file name syntax
  817. and Unix syntax.  This is so that all the standard Lisp libraries can
  818. specify file names in Unix syntax and work properly on VMS without
  819. change.
  820.  
  821. * Menu:
  822.  
  823. * File Name Components::  The directory part of a file name, and the rest.
  824. * Directory Names::       A directory's name as a directory
  825.                             is different from its name as a file.
  826. * Relative File Names::   Some file names are relative to a current directory.
  827. * File Name Expansion::   Converting relative file names to absolute ones.
  828. * Unique File Names::     Generating names for temporary files.
  829. * File Name Completion::  Finding the completions for a given file name.
  830.  
  831.  
  832. 
  833. File: elisp,  Node: File Name Components,  Next: Directory Names,  Up: File Names
  834.  
  835. File Name Components
  836. --------------------
  837.  
  838.    The operating system groups files into directories.  To specify a
  839. file, you must specify the directory, and the file's name in that
  840. directory.  Therefore, a file name in Emacs is considered to have two
  841. main parts: the "directory name" part, and the "nondirectory" part
  842. (or "file name within the directory").  Either part may be empty. 
  843. Concatenating these two parts reproduces the original file name.
  844.  
  845.    On Unix, the directory part is everything up to and including the
  846. last slash; the nondirectory part is the rest.  The rules in VMS
  847. syntax are complicated.
  848.  
  849.    For some purposes, the nondirectory part is further subdivided
  850. into the name and the version number.  On Unix, only backup files
  851. have version numbers in their names; on VMS, every file has a version
  852. number, but most of the time the file name actually used in Emacs
  853. omits the version number.  Version numbers are found mostly in
  854. directory lists.
  855.  
  856.  * Function: file-name-directory FILENAME
  857.      This function returns the directory part of FILENAME (or `nil'
  858.      if FILENAME does not include a directory part).  On Unix, the
  859.      function returns a string ending in a slash.  On VMS, it returns
  860.      a string ending in one of the three characters `:', `]', or `>'.
  861.  
  862.           (file-name-directory "lewis/foo")     ; Unix example
  863.                => "lewis/"
  864.           (file-name-directory "foo")           ; Unix example
  865.                => nil
  866.           (file-name-directory "[X]FOO.TMP")    ; VMS example
  867.                => "[X]"
  868.  
  869.  * Function: file-name-nondirectory FILENAME
  870.      This function returns the nondirectory part of FILENAME.
  871.  
  872.           (file-name-nondirectory "lewis/foo")
  873.                => "foo"
  874.           (file-name-nondirectory "foo")
  875.                => "foo"
  876.           ;; The following example is accurate only on VMS.
  877.           (file-name-nondirectory "[X]FOO.TMP")
  878.                => "FOO.TMP"
  879.  
  880.  * Function: file-name-sans-versions FILENAME
  881.      This function returns FILENAME without any file version numbers,
  882.      backup version numbers, or trailing tildes.
  883.  
  884.           (file-name-sans-versions "~rms/foo.~1~")
  885.                => "~rms/foo"
  886.           (file-name-sans-versions "~rms/foo~")
  887.                => "~rms/foo"
  888.           (file-name-sans-versions "~rms/foo")
  889.                => "~rms/foo"
  890.           ;; The following example applies to VMS only.
  891.           (file-name-sans-versions "foo;23")
  892.                => "foo"
  893.  
  894.  
  895. 
  896. File: elisp,  Node: Directory Names,  Next: Relative File Names,  Prev: File Name Components,  Up: File Names
  897.  
  898. Directory Names
  899. ---------------
  900.  
  901.    A "directory name" is the name of a directory.  A directory is a
  902. kind of file, and it has a file name, which is related to the
  903. directory name but not identical to it.  (This is not quite the same
  904. as the usual Unix terminology.)  These two different names for the
  905. same entity are related by a syntactic transformation.  On Unix, this
  906. is simple: a directory name ends in a slash, whereas the directory's
  907. name as a file lacks that slash.  On VMS, the relationship is more
  908. complicated.
  909.  
  910.    The difference between a directory name and its name as a file is
  911. subtle but crucial.  When an Emacs variable or function argument is
  912. described as being a directory name, a file name of a directory is
  913. not acceptable.
  914.  
  915.    All of these functions take a single argument, FILENAME, which
  916. must be a string.  Environment variable substitutions such as
  917. `$HOME', and the symbols `~', and `..', are *not* expanded.  Use
  918. `expand-file-name' or `substitute-in-file-name' for that (*note File
  919. Name Expansion::.).
  920.  
  921.  * Function: file-name-as-directory FILENAME
  922.      This function returns a string representing FILENAME in a form
  923.      that the operating system will interpret as the name of a
  924.      directory.  In Unix, this means that a slash is appended to the
  925.      string.  On VMS, the function converts a string of the form
  926.      `[X]Y.DIR.1' to the form `[X.Y]'.
  927.  
  928.           (file-name-as-directory "~rms/lewis")
  929.                => "~rms/lewis/"
  930.  
  931.  * Function: directory-file-name DIRNAME
  932.      This function returns a string representing DIRNAME in a form
  933.      that the operating system will interpret as the name of a file. 
  934.      On Unix, this means that a final slash is removed from the
  935.      string.  On VMS, the function converts a string of the form
  936.      `[X.Y]' to `[X]Y.DIR.1'.
  937.  
  938.           (directory-file-name "~lewis/")
  939.                => "~lewis"
  940.  
  941.  
  942. 
  943. File: elisp,  Node: Relative File Names,  Next: File Name Expansion,  Prev: Directory Names,  Up: File Names
  944.  
  945. Absolute and Relative File Names
  946. --------------------------------
  947.  
  948.    All the directories in the file system form a tree starting at the
  949. root directory.  A file name can specify all the directory names
  950. starting from the root of the tree; then it is called an "absolute"
  951. file name.  Or it can specify the position of the file in the tree
  952. relative to a default directory; then it is called an "relative" file
  953. name.  On Unix, an absolute file name starts with a slash or a tilde
  954. (`~'), and a relative one does not.  The rules on VMS are complicated.
  955.  
  956.  * Function: file-name-absolute-p FILENAME
  957.      This function returns `t' if file FILENAME is an absolute file
  958.      name, `nil' otherwise.  On VMS, this function understands both
  959.      Unix syntax and VMS syntax.
  960.  
  961.           (file-name-absolute-p "~rms/foo")
  962.                => t
  963.           (file-name-absolute-p "rms/foo")
  964.                => nil
  965.           (file-name-absolute-p "$HOME")
  966.                => nil
  967.           (file-name-absolute-p "/user/rms/foo")
  968.                => t
  969.  
  970.  
  971. 
  972. File: elisp,  Node: File Name Expansion,  Next: Unique File Names,  Prev: Relative File Names,  Up: File Names
  973.  
  974. Functions that Expand Filenames
  975. -------------------------------
  976.  
  977.    "Expansion" of a file name means converting a relative file name
  978. to an absolute one.  Since this is done relative to a default
  979. directory, you must specify the default directory name as well as the
  980. file name to be expanded.  Expansion also canonicalizes file names by
  981. eliminating redundancies such as `./' and `NAME/../'.
  982.  
  983.  * Function: expand-file-name FILENAME &optional DIRECTORY
  984.      This function converts FILENAME to an absolute file name.  If
  985.      DIRECTORY is supplied, it is the directory to start with if
  986.      FILENAME is relative.  Otherwise, the current buffer's value of
  987.      `default-directory' is used.  For example:
  988.  
  989.           (expand-file-name "foo")
  990.                => "/xcssun/users/rms/lewis/foo"
  991.           (expand-file-name "../foo")
  992.                => "/xcssun/users/rms/foo"
  993.           (expand-file-name "foo" "/usr/spool")
  994.                => "/usr/spool/foo"
  995.           (expand-file-name "$HOME/foo")
  996.                => "/xcssun/users/rms/lewis/$HOME/foo"
  997.  
  998.      Filenames containing `.' or `..' are simplified to their
  999.      canonical form:
  1000.  
  1001.           (expand-file-name "bar/../foo")
  1002.                => "/xcssun/users/rms/lewis/foo"
  1003.  
  1004.      `~/' is expanded into the user's home directory.  A `/' or `~'
  1005.      following a `/' is taken to be the start of an absolute file
  1006.      name that overrides what precedes it, so everything before that
  1007.      `/' or `~' is deleted.  For example:
  1008.  
  1009.           (expand-file-name "/a1/gnu//usr/local/lib/emacs/etc/MACHINES")
  1010.                => "/usr/local/lib/emacs/etc/MACHINES"
  1011.           (expand-file-name "/a1/gnu/~/foo")
  1012.                => "/xcssun/users/rms/foo"
  1013.  
  1014.      In both cases, `/a1/gnu/' has been discarded because an absolute
  1015.      file name follows it.
  1016.  
  1017.      Note that `expand-file-name' does *not* expand environment
  1018.      variables; that is done only by `substitute-in-file-name'.
  1019.  
  1020.  * Variable: default-directory
  1021.      The value of this buffer-local variable is the default directory
  1022.      for the current buffer.  It is local in every buffer. 
  1023.      `expand-file-name' uses the default directory when its second
  1024.      argument is `nil'.
  1025.  
  1026.      On Unix systems, the value is always a string ending with a slash.
  1027.  
  1028.           default-directory
  1029.                => "/user/lewis/manual/"
  1030.  
  1031.  * Function: substitute-in-file-name FILENAME
  1032.      This function replaces environment variables names in FILENAME
  1033.      with the values to which they are set by the operating system. 
  1034.      Following standard Unix shell syntax, `$' is the prefix to
  1035.      substitute an environment variable value.
  1036.  
  1037.      The environment variable name is the series of alphanumeric
  1038.      characters (including underscores) that follow the `$'.  If the
  1039.      character following the `$' is a `{', then the variable name is
  1040.      everything up to the matching `}'.
  1041.  
  1042.      Here we assume that the environment variable `HOME', which holds
  1043.      the user's home directory name, has the value `/xcssun/users/rms'.
  1044.  
  1045.           (substitute-in-file-name "$HOME/foo")
  1046.                => "/xcssun/users/rms/foo"
  1047.  
  1048.      If a `~' or a `/' appears following a `/', after substitution,
  1049.      everything before the following `/' is discarded:
  1050.  
  1051.           (substitute-in-file-name "bar/~/foo")
  1052.                => "~/foo"
  1053.           (substitute-in-file-name "/usr/local/$HOME/foo")
  1054.                => "/xcssun/users/rms/foo"
  1055.  
  1056.      On VMS, `$' substitution is not done, so this function does
  1057.      nothing on VMS except discard superfluous initial components as
  1058.      shown above.
  1059.  
  1060.  
  1061. 
  1062. File: elisp,  Node: Unique File Names,  Next: File Name Completion,  Prev: File Name Expansion,  Up: File Names
  1063.  
  1064. Generating Unique File Names
  1065. ----------------------------
  1066.  
  1067.    Some programs need to write temporary files.  Here is the usual
  1068. way to construct a name for such a file:
  1069.  
  1070.      (concat "/tmp/" (make-temp-name NAME-OF-APPLICATION))
  1071.  
  1072. The directory `/tmp/' is chosen because that is the standard place on
  1073. Unix for temporary files.  The task of `make-temp-name' is to prevent
  1074. two different users or two different jobs from trying to use the same
  1075. name.
  1076.  
  1077.  * Function: make-temp-name STRING
  1078.      This function generates string that can be used as a unique name.
  1079.      The name will start with the prefix STRING, and finish with a
  1080.      number that is different in each Emacs job.
  1081.  
  1082.           (make-temp-name "foo")
  1083.                => "foo021304"
  1084.           (make-temp-name "foo")
  1085.                => "foo021304"
  1086.  
  1087.      To prevent conflicts among different application libraries run
  1088.      in the same Emacs, each application should have its own STRING. 
  1089.      The number added to the end of the name distinguishes between
  1090.      the same application running in different Emacses.
  1091.  
  1092.  
  1093. 
  1094. File: elisp,  Node: File Name Completion,  Prev: Unique File Names,  Up: File Names
  1095.  
  1096. File Name Completion
  1097. --------------------
  1098.  
  1099.    This section describes low-level subroutines for completing a file
  1100. name.  For other completion functions, see *Note Completion::.
  1101.  
  1102.  * Function: file-name-all-completions PARTIAL-FILENAME DIRECTORY
  1103.      This function returns a list of all possible completions for a
  1104.      file whose name starts with PARTIAL-FILENAME in directory
  1105.      DIRECTORY.  The order of the completions is the order of the
  1106.      files in the directory, which is unpredictable and conveys no
  1107.      useful information.
  1108.  
  1109.      The argument PARTIAL-FILENAME must be a file name containing no
  1110.      directory part and no slash.  The current buffer's default
  1111.      directory is prepended to DIRECTORY, if DIRECTORY is not an
  1112.      absolute file name.
  1113.  
  1114.      In the following example, suppose that the current default
  1115.      directory, `~rms/lewis', has five files whose names begin with
  1116.      `f': `foo', `file~', `file.c', `file.c.~1~', and `file.c.~2~'.
  1117.  
  1118.           (file-name-all-completions "f" "")
  1119.                => ("foo" "file~" "file.c.~2~" "file.c.~1~" "file.c")
  1120.           
  1121.           (file-name-all-completions "fo" "")  
  1122.                => ("foo")
  1123.  
  1124.  * Function: file-name-completion FILENAME DIRECTORY
  1125.      This function completes the file name FILENAME in directory
  1126.      DIRECTORY.  It returns the longest prefix common to all file
  1127.      names in directory DIRECTORY that start with FILENAME.
  1128.  
  1129.      If only one match exists and FILENAME matches it exactly, the
  1130.      function returns `t'.  The function returns `nil' if directory
  1131.      DIRECTORY contains no name starting with FILENAME.
  1132.  
  1133.      In the following example, suppose that the current default
  1134.      directory has five files whose names begin with `f': `foo',
  1135.      `file~', `file.c', `file.c.~1~', and `file.c.~2~'.
  1136.  
  1137.           (file-name-completion "fi" "")
  1138.                => "file"
  1139.           
  1140.           (file-name-completion "file.c.~1" "")
  1141.                => "file.c.~1~"
  1142.           
  1143.           (file-name-completion "file.c.~1~" "")
  1144.                => t
  1145.           
  1146.           (file-name-completion "file.c.~3" "")
  1147.                => nil
  1148.  
  1149.  * User Option: completion-ignored-extensions
  1150.      `file-name-completion' usually ignores file names that end in
  1151.      any string in this list.  It does not ignore them when all the
  1152.      possible completions end in one of these suffixes or when a
  1153.      buffer showing all possible completions is displayed.
  1154.  
  1155.      A typical value might look like this:
  1156.  
  1157.           completion-ignored-extensions
  1158.                => (".o" ".elc" "~" ".dvi")
  1159.  
  1160.  
  1161. 
  1162. File: elisp,  Node: Backups and Auto-Saving,  Next: Buffers,  Prev: Files,  Up: Top
  1163.  
  1164. Backups and Auto-Saving
  1165. ***********************
  1166.  
  1167.    Backup files and auto-save files are two methods by which Emacs
  1168. tries to protect the user from the consequences of crashes or of the
  1169. user's own errors.  Auto-saving preserves the text from earlier in
  1170. the current editing session; backup files preserve file contents
  1171. prior to the current session.
  1172.  
  1173. * Menu:
  1174.  
  1175. * Backup Files::   How backup files are made; how their names are chosen.
  1176. * Auto-Saving::    How auto-save files are made; how their names are chosen.
  1177. * Reverting::      `revert-buffer', and how to customize what it does.
  1178.  
  1179.  
  1180. 
  1181. File: elisp,  Node: Backup Files,  Next: Auto-Saving,  Prev: Backups and Auto-Saving,  Up: Backups and Auto-Saving
  1182.  
  1183. Backup Files
  1184. ============
  1185.  
  1186.    A "backup file" is a copy of the old contents of a file you are
  1187. editing.  Emacs makes a backup file the first time you save a buffer
  1188. into its visited file.  Normally, this means that the backup file
  1189. contains the contents of the file as it was before the current
  1190. editing session.  The contents of the backup file normally remain
  1191. unchanged once it exists.
  1192.  
  1193.    Backups are usually made by renaming the visited file to a new name.
  1194. Optionally, you can specify that backup files should be made by
  1195. copying the visited file.  This choice makes a difference for files
  1196. with multiple names; it also can affect whether the edited file
  1197. remains owned by the original owner or becomes owned by the user
  1198. editing it.
  1199.  
  1200.    By default, Emacs makes a single backup file for each file edited.
  1201. You can alternatively request numbered backups; then each new backup
  1202. file gets a new name.  You can delete old numbered backups when you
  1203. don't want them any more, or Emacs can delete them automatically.
  1204.  
  1205. * Menu:
  1206.  
  1207. * Making Backups::     How Emacs makes backup files, and when.
  1208. * Rename or Copy::     Two alternatives: renaming the old file or copying it.
  1209. * Numbered Backups::   Keeping multiple backups for each source file.
  1210. * Backup Names::       How backup file names are computed; customization.
  1211.  
  1212.  
  1213. 
  1214. File: elisp,  Node: Making Backups,  Next: Rename or Copy,  Prev: Backup Files,  Up: Backup Files
  1215.  
  1216. Making Backup Files
  1217. -------------------
  1218.  
  1219.  * Function: backup-buffer
  1220.      This function makes a backup of the file visited by the current
  1221.      buffer, if appropriate.  It is called by `save-buffer' before
  1222.      saving the buffer the first time.
  1223.  
  1224.  * Variable: buffer-backed-up
  1225.      This buffer-local variable indicates whether this buffer's file
  1226.      has been backed up on account of this buffer.  If it is
  1227.      non-`nil', then the backup file has been written.  Otherwise,
  1228.      the file should be backed up when it is next saved (if backup
  1229.      files are enabled).
  1230.  
  1231.  * Variable: make-backup-files
  1232.      This variable determines whether or not backup files will be
  1233.      created.  If it is non-`nil', then Emacs will create a backup of
  1234.      each file when it is saved for the first time.
  1235.  
  1236.      The following example shows how to change the
  1237.      `make-backup-files' variable only in the `RMAIL' buffer and not
  1238.      elsewhere.  Setting it `nil' stops Emacs from making backups of
  1239.      the `RMAIL' file, which may save disk space.  (You would put
  1240.      this code in your `.emacs' file.)
  1241.  
  1242.           (setq rmail-mode-hook 
  1243.                 (function (lambda ()
  1244.                             (make-local-variable 'make-backup-files)
  1245.                             (setq make-backup-files nil)))
  1246.  
  1247.  
  1248.